package com.sk.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.sk.dao.UserDao;
import com.sk.domain.User;

@Repository("userService")
public class UserService {
	@Autowired
	private UserDao ud;

	public User findByUname(String uname, String pwd) {
		
		User user= new User();
		user.setUname(uname);
		user.setUpwd(pwd);
		User u = ud.findForObject(user);
		if(u != null){
			return u;
		}
		// TODO Auto-generated method stub
		return null;
	}

	public boolean addUser(String uname, String pwd) {
		// TODO Auto-generated method stub
		User user= new User();
		user.setUname(uname);
		user.setUpwd(pwd);
		try{
			ud.add(user);
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
		return true;
	}

}
